package com.lswms.modules.job.task;

import java.util.GregorianCalendar;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.lswms.modules.job.dao.ScheduleJobLogDao;
import com.lswms.modules.job.entity.ScheduleJobLogEntity;
import com.lswms.modules.lswms.dao.stock.InventoryDao;
import com.lswms.modules.lswms.entity.stock.InventoryEntity;

import lombok.extern.slf4j.Slf4j;

/**
 * 
 * @author Administrator
 *
 */
@Component
@Slf4j
public class AutoTasks {

	// @Autowired
//	private TaskDao taskDao;
//	
//	@Autowired
//	private TaskRecordDao taskRecordDao;
//
//    @Autowired
//    private StockInDetailService stockInDetailService;
//
//    @Autowired
//    private StockOutService stockOutService;
//    
//    @Autowired
//    private LocateService locateService;
//    
//    @Autowired
//    private FinishstockinreturnService finishstockinreturnService;

	@Autowired
	InventoryDao inventoryBao;
	@Autowired
	ScheduleJobLogDao scheduleJobLogDao ;
	/**
	 * 扫描状态10（3s一次）
	 */
	@Scheduled(cron = "*/3 * * * * ?")
	public void prodApply() {
		log.info("扫描完成状态-----------");
		try {
			UpdateWrapper<InventoryEntity> deleteInventory = new UpdateWrapper<InventoryEntity>();
			deleteInventory.eq("qty", 0);
			deleteInventory.eq("pickqty", 0);
			deleteInventory.eq("putqty", 0);

			inventoryBao.delete(deleteInventory);
			
			GregorianCalendar gregorianCalendar = new GregorianCalendar();
			gregorianCalendar.add(5, -3) ;
			
			UpdateWrapper<ScheduleJobLogEntity> delete = new UpdateWrapper<ScheduleJobLogEntity>();
			delete.le("create_Date", gregorianCalendar.getTime());
			scheduleJobLogDao.delete(delete) ;
		} catch (Exception e) {
			e.printStackTrace();
			log.error(e.getMessage());
		}
	}

}
